# IMPORTANT: RUN THIS CELL IN ORDER TO IMPORT YOUR KAGGLE DATA SOURCES
# TO THE CORRECT LOCATION (/kaggle/input) IN YOUR NOTEBOOK,
# THEN FEEL FREE TO DELETE THIS CELL.
# NOTE: THIS NOTEBOOK ENVIRONMENT DIFFERS FROM KAGGLE'S PYTHON
# ENVIRONMENT SO THERE MAY BE MISSING LIBRARIES USED BY YOUR
# NOTEBOOK.
import os
import sys
from tempfile import NamedTemporaryFile
from urllib.request import urlopen
from urllib.parse import unquote, urlparse
from urllib.error import HTTPError
from zipfile import ZipFile
import tarfile
import shutil
CHUNK_SIZE = 40960
DATA_SOURCE_MAPPING = 'confused-eeg:https%3A%2F%2Fstorage.googleapis.com%2Fkaggle-data-sets%2F106%2F24522%2Fbundle%2Farchive.zip%3FX-Goog-Algorithm%3DGOOG4-RSA-SHA256%26X-Goog-Credential%3Dgcp-kaggle-com%2540kaggle-161607.iam.gserviceaccount.com%252F20240915%252Fauto%252Fstorage%252Fgoog4_request%26X-Goog-Date%3D20240915T103511Z%26X-Goog-Expires%3D259200%26X-Goog-SignedHeaders%3Dhost%26X-Goog-Signature%3D27045b8c49f7c5561b3b355ac7683bbbc3c9ef98639ffec5cc0b45b3f516f5348aa2e84dad7f1d47789bdf4966c1b5be03c86845c34245d6cbb9bee1368a8c59cbb5b6ce3fc968002f1c1391ec4614b73e689904f03b2215489ba9ee2a2b299e0d4f4157f35fc2de400efb0ba983c1fb5ca83b3e3267fd88683385f10a6debf5da1fe6d10e64c2e88cc3e346304a43ab170dec54605d048e1267d35ffab36797910472fc06e7b2662f2fcb27fedae8165798e040e979c9dc96a3839d0cb52ffab5cc0ab662c700aece26ab073f03e2c6a2f0fa0698b92c4573139e0f57dff238865e21548ec3698285c51758063a8e14a4cbb8030eddb0d256ff9d4d5ccc05f5,eeg-brainwave-dataset-feeling-emotions:https%3A%2F%2Fstorage.googleapis.com%2Fkaggle-data-sets%2F93959%2F218459%2Fbundle%2Farchive.zip%3FX-Goog-Algorithm%3DGOOG4-RSA-SHA256%26X-Goog-Credential%3Dgcp-kaggle-com%2540kaggle-161607.iam.gserviceaccount.com%252F20240915%252Fauto%252Fstorage%252Fgoog4_request%26X-Goog-Date%3D20240915T103511Z%26X-Goog-Expires%3D259200%26X-Goog-SignedHeaders%3Dhost%26X-Goog-Signature%3D32994d4230af30f4a221fc09031a57133ac9ffcba11af2366609795e1925551d4f3af312f5fa21c1fd9fb5aebe01b39042a324292fa977e4d3c3b6ce1b8cb2dd5b16bd3a6138cfa27ead12dcc7f9972e8cbc869e439c8e085c6c0299ee2fd132b63b90b5aee24f31903351fea12ae34ab2ba27441367f5dcd9ba6f9104014be69cb2cbd162c181b920cbdc32c89f9bdbec7bd24f3c83b9c9a05829f998a8b2a4fe9e05b8b73dc75f6cf22fcd1be115658dbfdc3c659364dfb44434bf77af4e97137c191b4565adc944b37571090aaa0d80030169b015c67cc71bba8b8402ed5a4c0b5738c4f6aace0d66e6f6d2fb44bff6e7bd88abe054dc356cf5b890584130,eeg-data-for-mental-attention-state-detection:https%3A%2F%2Fstorage.googleapis.com%2Fkaggle-data-sets%2F159484%2F365400%2Fbundle%2Farchive.zip%3FX-Goog-Algorithm%3DGOOG4-RSA-SHA256%26X-Goog-Credential%3Dgcp-kaggle-com%2540kaggle-161607.iam.gserviceaccount.com%252F20240915%252Fauto%252Fstorage%252Fgoog4_request%26X-Goog-Date%3D20240915T103511Z%26X-Goog-Expires%3D259200%26X-Goog-SignedHeaders%3Dhost%26X-Goog-Signature%3D4737a2c56b73344d42c4bdec9dde7ab4aa4894559c3fe6b839528fe4d41ccc7d39c958524f525168766aee8d4f96ac5a077219d2207752be458e737c8e5e4458dfe4f59117c3e92a87167e0295e5c1f8e26d5f912b5d402cae3d7597177a7c11bbae9b073f4dcdd0883b97a8e48d01f3adcf365527be8f732eed874ef8f602af346c7c7dfd0c78387d02f5dab6fc9619e6530653cea631349c549e542b8281173aeff18bcb1dfe0fdd0363938599bf15616ec7a287bd67c42a44505ddb0c7be5fffa17a5f9fbbf6e219266120ee614892e822daaadd02daadd43d5f58eea042306f32503a1a820ece8d4998b54564259be81f810307d8f5cc7be6c455e4d95f4,rem-and-nrem-sleep-classification:https%3A%2F%2Fstorage.googleapis.com%2Fkaggle-data-sets%2F3520887%2F6140055%2Fbundle%2Farchive.zip%3FX-Goog-Algorithm%3DGOOG4-RSA-SHA256%26X-Goog-Credential%3Dgcp-kaggle-com%2540kaggle-161607.iam.gserviceaccount.com%252F20240915%252Fauto%252Fstorage%252Fgoog4_request%26X-Goog-Date%3D20240915T103511Z%26X-Goog-Expires%3D259200%26X-Goog-SignedHeaders%3Dhost%26X-Goog-Signature%3D01e3453d1baeaaad19ad1015f701b344c1bcd1b155836d9080032d34bb3a3bf31afe58a7b301bc9c998d360880cbfe86c90755c3383ed23888541e5d7f117df6a08235c1418462fd0fc60203f0c120ed184838836087017b8733a8f4a74e2c72a870f4f96ac3c601e8575ebff7ccefdcfa8cf6216610ae30786beb14e11db9234b392066943db8653eecf5871704e87ceba7258ccdebe5a46b0b50bb0ddda58b48295d76bdb7de3744e49126b5587ca597dd2ca706b3c7e5b6f35cf3de2a24231f45db889b10ae968d990cd763231f5cca17ae8c26f5cfe31ba5a55ca4505d69572e7c223c6cfafe42fcac2b837a07ea8d987f2b9b268c253805d9153e22342c,sleepy-driver-eeg-brainwave-data:https%3A%2F%2Fstorage.googleapis.com%2Fkaggle-data-sets%2F3684204%2F6391469%2Fbundle%2Farchive.zip%3FX-Goog-Algorithm%3DGOOG4-RSA-SHA256%26X-Goog-Credential%3Dgcp-kaggle-com%2540kaggle-161607.iam.gserviceaccount.com%252F20240915%252Fauto%252Fstorage%252Fgoog4_request%26X-Goog-Date%3D20240915T103511Z%26X-Goog-Expires%3D259200%26X-Goog-SignedHeaders%3Dhost%26X-Goog-Signature%3D0c03b8a4cbd409c7dcfc383adcaa9d4ee502192aae58b13dc9af018616c0162112d2a5be3e8853aafe943f7b84f6cab1c633ada5bb598ec47eadf00803dacdbd5ba5ee09c732c681c508ca8095636196ae4084af0f2eb0cc196defe8afac2becb3ac39149684a150c11b7b7e99a9aaf5c746c873b836ad0cd1e546c76e97cb6045dd4661206a53786f8661566ef613adcd970dc0b23fe5d7fbf43dd3ca2575a33bbfce261a454424c76f0b607331dd8da5acfe57551f36317209dd8ac6a8a1fdf93b02fdc77d4e8534bcea6ee2b08fe1f1f5ca781e1639e3ca2dc12103f3ce741a6149086f3f2811b24df3da4dca02015912cd8045bec0d4e192519cd32b3f82'
KAGGLE_INPUT_PATH='kaggle/input'
KAGGLE_WORKING_PATH='kaggle/working'
KAGGLE_SYMLINK='kaggle'
os.makedirs(KAGGLE_SYMLINK)
os.makedirs(KAGGLE_INPUT_PATH, 0o777)
os.makedirs(KAGGLE_WORKING_PATH, 0o777)
for data_source_mapping in DATA_SOURCE_MAPPING.split(','):
directory, download_url_encoded = data_source_mapping.split(':')
download_url = unquote(download_url_encoded)
filename = urlparse(download_url).path
destination_path = os.path.join(KAGGLE_INPUT_PATH, directory)
try:
with urlopen(download_url) as fileres, NamedTemporaryFile() as tfile:
total_length = fileres.headers['content-length']
print(f'Downloading {directory}, {total_length} bytes compressed')
dl = 0
data = fileres.read(CHUNK_SIZE)
while len(data) > 0:
dl += len(data)
tfile.write(data)
done = int(50 * dl / int(total_length))
sys.stdout.write(f"\r[{'=' * done}{' ' * (50-done)}] {dl} bytes downloaded")
sys.stdout.flush()
data = fileres.read(CHUNK_SIZE)
if filename.endswith('.zip'):
with ZipFile(tfile) as zfile:
zfile.extractall(destination_path)
else:
with tarfile.open(tfile.name) as tarfile:
tarfile.extractall(destination_path)
print(f'\nDownloaded and uncompressed: {directory}')
except HTTPError as e:
print(f'Failed to load (likely expired) {download_url} to path {destination_path}')
continue
except OSError as e:
print(f'Failed to load {download_url} to path {destination_path}')
continue
print('Data source import complete.')
Downloading confused-eeg, 114134669 bytes compressed [==================================================] 114134669 bytes downloaded Downloaded and uncompressed: confused-eeg Downloading eeg-brainwave-dataset-feeling-emotions, 12498935 bytes compressed [==================================================] 12498935 bytes downloaded Downloaded and uncompressed: eeg-brainwave-dataset-feeling-emotions Downloading eeg-data-for-mental-attention-state-detection, 584453490 bytes compressed [================================================= ] 579624960 bytes downloaded Downloaded and uncompressed: eeg-data-for-mental-attention-state-detection Downloading rem-and-nrem-sleep-classification, 11654069 bytes compressed [==================================================] 11654069 bytes downloaded Downloaded and uncompressed: rem-and-nrem-sleep-classification Downloading sleepy-driver-eeg-brainwave-data, 93280 bytes compressed [==================================================] 93280 bytes downloaded Downloaded and uncompressed: sleepy-driver-eeg-brainwave-data Data source import complete.
OPTIME¶
Our brain is the fastest and most incredible processor in existence. With our machine learning algorithms we look to tap into the unconsious of our mind to help us live a better life. Using wearable EEG (electroenecephalogram) devices like the one pictured below we are able to read the brain waves that our mind produces. We are able to use this information to detect information like our moods, sleep cycles, focus, and even uses in medical cases like detecting seizures.
With our machine learning algorithms that we have dubbed OPTIME, we look to optmize our daily lives and routines and track our performance. We will be able to read the data and determine optimal tasks to undertake. Let's say for instance you are sitting on the couch and have high magnitude of gamma waves coming into your head, our software will suggest that you get up and do some high energy or challenging tasks in order to take advantage of your current state.